3557ee
@@ -79,11 +79,11 @@
static URI getValidatedURI(HiveConf conf, String dcPath) throws SemanticExceptio
       // generate absolute path relative to home directory
       if (!path.startsWith("/")) {
         if (testMode) {
-          path = new Path(System.getProperty("build.dir.hive"),
-              path).toString();
+          path = (new Path(System.getProperty("build.dir.hive"),
+              path)).toUri().getPath();
         } else {
-          path = new Path(new Path("/user/" + System.getProperty("user.name")),
-              path).toString();
+          path = (new Path(new Path("/user/" + System.getProperty("user.name")),
+              path)).toUri().getPath();
         }
       }
       // set correct scheme and authority
@@ -144,8 +144,8 @@
public static String relativeToAbsolutePath(HiveConf conf, String location) thro
       String authority = uri.getAuthority();
       String path = uri.getPath();
       if (!path.startsWith("/")) {
-          path = new Path(System.getProperty("build.dir.hive"),
-              path).toString();
+          path = (new Path(System.getProperty("build.dir.hive"),
+              path)).toUri().getPath();
       }
       if (StringUtils.isEmpty(scheme)) {
           scheme = "pfile";
@@ -201,11 +201,12 @@
public static void createExportDump(FileSystem fs, Path metadataPath, org.apache
     }
   }
 
-  public static Map.Entry<Table, List<Partition>> 
-      readMetaData(FileSystem fs, Path metadataPath) 
+  public static Map.Entry<Table, List<Partition>>
+      readMetaData(FileSystem fs, Path metadataPath)
       throws IOException, SemanticException {
+    FSDataInputStream mdstream = null;
     try {
-      FSDataInputStream mdstream = fs.open(metadataPath);
+      mdstream = fs.open(metadataPath);
       byte[] buffer = new byte[1024];
       ByteArrayOutputStream sb = new ByteArrayOutputStream();
       int read = mdstream.read(buffer);
@@ -238,6 +239,10 @@
public static void createExportDump(FileSystem fs, Path metadataPath, org.apache
       throw new SemanticException(ErrorMsg.GENERIC_ERROR.getMsg("Error in serializing metadata"), e);
     } catch (TException e) {
       throw new SemanticException(ErrorMsg.GENERIC_ERROR.getMsg("Error in serializing metadata"), e);
+    } finally {
+      if (mdstream != null) {
+        mdstream.close();
+      }
     }
   }
 
